package com.bt.dmdb.controller.impl;

import java.io.Serializable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bt.dmdb.controller.GenericCtrl;
import com.bt.dmdb.service.GenericService;

public abstract class GenericCtrlImpl<T, ID extends Serializable> implements GenericCtrl<T, ID> {

    abstract public GenericService<T, ID> gs();

    @Override
    @ResponseBody
    @RequestMapping(value = "insert", method = RequestMethod.POST)
    public ID insert(@RequestBody T t) {
        return gs().insert(t);
    }

    @Override
    @ResponseBody
    @RequestMapping(value = "create", method = RequestMethod.POST)
    public T create(@RequestBody T t) {
        return gs().create(t);
    }

    @Override
    @ResponseBody
    @RequestMapping(value = "retreive", method = { RequestMethod.POST, RequestMethod.GET })
    public T retreive(@RequestBody ID id) {
        return gs().retreive(id);
    }

    @Override
    @ResponseBody
    @RequestMapping(value = "update", method = RequestMethod.POST)
    public void update(@RequestBody T t) {
        gs().update(t);
    }

    @Override
    @ResponseBody
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    public void delete(@RequestBody T t) {
        gs().delete(t);
    }
}
